//
//  BaseWebViewController.swift
//  BaseFramework
//
//  Created by 杨东宝 on 2020/5/21.
//  Copyright © 2020 杨东宝. All rights reserved.
//

import UIKit

class BaseWebViewController: GTMWebViewController {

       override func viewDidLoad() {
           self.backIconName = "icon_nav_back"
           super.viewDidLoad()
           self.registApiForJs()
       }
       
       override func webDidLoad() {
           super.webDidLoad()
          self.webView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight - kTopHeight)
       }
    
       func registApiForJs() {
           // MARK: - JS调用原生 Events
           // 简单测试方法
           self.registApi(method: "test") { [weak self] (body) in
              
           }
           // 扫描功能API
           self.registApi(method: "scanBarcode") { [weak self] (body) in
               
           }
       }
       
       // MARK: - 原生调用JS Events
       @objc func onCallJsMethod() {
           let wkwebV = self.webView
           wkwebV?.evaluateJavaScript("changeColor();", completionHandler: nil)
       } 
}
